<?php

class Tags extends CActiveRecord
{
    public $tag_name;

	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	public function tableName()
	{
		return '{{tags}}';
	}

	public function rules()
	{
		return array(
			array('tag_name', 'required'),
			array('tag_name', 'unique'),
			array('tag_name', 'length', 'max'=>22, 'min'=>2),
			array('id, tag_name, tag_count', 'safe', 'on'=>'search'),
		);
	}

	public function relations()
	{
		return array(
		);
	}

	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'tag_name' => '标签名称',
			'tag_count' => '浏览次数',
		);
	}

	public function search()
	{
		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('tag_name',$this->tag_name,true);
		$criteria->compare('tag_count',$this->tag_count);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}